package com.sq.goodline.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sq.goodline.config.JobConfig;
import com.sq.goodline.controller.dto.AccessTokenDto;
import com.sq.goodline.controller.dto.AudioDetailPushDto;
import com.sq.goodline.controller.dto.CallDetailPushDto;
import com.sq.goodline.controller.dto.CallDetailPushResultDto;
import com.sq.goodline.service.AccessTokenService;
import com.sq.goodline.service.AxBingdingService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/Task")
public class TaskController {

	@Autowired
	JobConfig jobConfig;
	@Autowired
	AccessTokenService accessTokenService;
	@Autowired
	AxBingdingService axBingdingService;
	
	@GetMapping(value = "/axbToken")
	public AccessTokenDto axbToken() {
		return accessTokenService.accessToken();
	}
	
	@GetMapping(value = "/axRemove")
	public String axRemove(@RequestParam(value = "callnumx",required=true) String callNumX) {
		return axBingdingService.doAxRemove(callNumX);
	}
	
	
	
	 /**demo。。。。。*/
    @PostMapping(value = "/demoCallPush")
    public List<CallDetailPushResultDto> demoCallPush(@RequestBody List<CallDetailPushDto> pushDtoList) {
    	List<CallDetailPushResultDto> resultList = new ArrayList<>();
    	for(CallDetailPushDto pushDto:pushDtoList) {
    		CallDetailPushResultDto resultDto = new CallDetailPushResultDto();
    		resultDto.setFlowno(pushDto.getFlowno());
    		resultDto.setResult(1);
    		resultList.add(resultDto);
    	}
    	return resultList;
    }
    
    @PostMapping(value = "/demoAudioPush")
    public List<CallDetailPushResultDto> demoAudioPush(@RequestBody List<AudioDetailPushDto> pushDtoList) {
    	List<CallDetailPushResultDto> resultList = new ArrayList<>();
    	for(AudioDetailPushDto pushDto:pushDtoList) {
    		CallDetailPushResultDto resultDto = new CallDetailPushResultDto();
    		resultDto.setFlowno(pushDto.getFlowno());
    		resultDto.setResult(1);
    		resultList.add(resultDto);
    	}
    	return resultList;
    }
}
